#ifndef OBJECTMANAGER_H
#define OBJECTMANAGER_H

// Libraries
#include <irrlicht.h>

// Namespaces
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

// Forward Declarations
class CGObject;
class CGMap;

// Classes
class ObjectManagerClass 
{

	public:

		ObjectManagerClass();
		~ObjectManagerClass();

		void Update(u32 TDeltaTime);
		void Render(const CGMap *TMap);
		void SetObjectDeletedCallback(void (* Callback)(CGObject *TObject)) { ObjectDeletedCallback = Callback; }

		void ClearObjects();
		void DeletesObjectsExcept(CGObject *TObject);
		CGObject *CreateObjectFromTemplate(int TTemplateID);
		CGObject *AddObject(CGObject *TObject);
		CGObject *AddObjectWithNetworkID(CGObject *TObject, int TNetworkID);
		void DeleteObject(CGObject *TObject);

		int GetObjectCount() const { return Objects.getSize(); }
		const list<CGObject *> &GetObjects() const { return Objects; }
		CGObject *GetObjectFromNetworkID(int TID);

	private:

		int GetNextNetworkID();
		list<CGObject *> Objects;

		// Networking
		CGObject **ObjectArray;
		void (* ObjectDeletedCallback)(CGObject *TObject);

		int NextNetworkID;
};

#endif
